{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Title: #Maximum Number of Words Found in Sentences"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Difficulty: #Easy"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Category Title: #Algorithms"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Tag Slug: #array #string"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Name Translated: #数组 #字符串"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Solution Name: mostWordsFound"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Translated Title: #句子中的最多单词数"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Translated Content:\n",
    "<p>一个 <strong>句子</strong>&nbsp;由一些 <strong>单词</strong>&nbsp;以及它们之间的单个空格组成，句子的开头和结尾不会有多余空格。</p>\n",
    "\n",
    "<p>给你一个字符串数组&nbsp;<code>sentences</code>&nbsp;，其中&nbsp;<code>sentences[i]</code>&nbsp;表示单个 <strong>句子</strong>&nbsp;。</p>\n",
    "\n",
    "<p>请你返回单个句子里 <strong>单词的最多数目</strong>&nbsp;。</p>\n",
    "\n",
    "<p>&nbsp;</p>\n",
    "\n",
    "<p><strong>示例 1：</strong></p>\n",
    "\n",
    "<pre><b>输入：</b>sentences = [\"alice and bob love leetcode\", \"i think so too\", <em><strong>\"this is great thanks very much\"</strong></em>]\n",
    "<b>输出：</b>6\n",
    "<b>解释：</b>\n",
    "- 第一个句子 \"alice and bob love leetcode\" 总共有 5 个单词。\n",
    "- 第二个句子 \"i think so too\" 总共有 4 个单词。\n",
    "- 第三个句子 \"this is great thanks very much\" 总共有 6 个单词。\n",
    "所以，单个句子中有最多单词数的是第三个句子，总共有 6 个单词。\n",
    "</pre>\n",
    "\n",
    "<p><strong>示例 2：</strong></p>\n",
    "\n",
    "<pre><b>输入：</b>sentences = [\"please wait\", <em><strong>\"continue to fight\"</strong></em>, <em><strong>\"continue to win\"</strong></em>]\n",
    "<b>输出：</b>3\n",
    "<b>解释：</b>可能有多个句子有相同单词数。\n",
    "这个例子中，第二个句子和第三个句子（加粗斜体）有相同数目的单词数。\n",
    "</pre>\n",
    "\n",
    "<p>&nbsp;</p>\n",
    "\n",
    "<p><strong>提示：</strong></p>\n",
    "\n",
    "<ul>\n",
    "\t<li><code>1 &lt;= sentences.length &lt;= 100</code></li>\n",
    "\t<li><code>1 &lt;= sentences[i].length &lt;= 100</code></li>\n",
    "\t<li><code>sentences[i]</code>&nbsp;只包含小写英文字母和&nbsp;<code>' '</code>&nbsp;。</li>\n",
    "\t<li><code>sentences[i]</code>&nbsp;的开头和结尾都没有空格。</li>\n",
    "\t<li><code>sentences[i]</code>&nbsp;中所有单词由单个空格隔开。</li>\n",
    "</ul>\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Description: [maximum-number-of-words-found-in-sentences](https://leetcode.cn/problems/maximum-number-of-words-found-in-sentences/description/)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Solutions: [maximum-number-of-words-found-in-sentences](https://leetcode.cn/problems/maximum-number-of-words-found-in-sentences/solutions/)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "test_cases = ['[\"alice and bob love leetcode\",\"i think so too\",\"this is great thanks very much\"]', '[\"please wait\",\"continue to fight\",\"continue to win\"]']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def mostWordsFound(self, sentences: List[str]) -> int:\n",
    "        ans = []\n",
    "        for i in sentences:\n",
    "            ans.append(len(i.split(' ')))\n",
    "        return max(ans)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def mostWordsFound(self, sentences: List[str]) -> int:\n",
    "        return max(i.count(' ') for i in sentences)+1\n",
    "             "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def mostWordsFound(self, sentences: List[str]) -> int:\n",
    "       \n",
    "        res_list = []\n",
    "        for i in range(len(sentences)):\n",
    "            words,count = 0,0\n",
    "            for j in sentences[i]:\n",
    "                if j == ' ':\n",
    "                    count += 1\n",
    "            words = count + 1\n",
    "            res_list.append(words)\n",
    "\n",
    "        return max(res_list)\n",
    "        \n",
    "       \n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def mostWordsFound(self, sentences: List[str]) -> int:\n",
    "        return max(s.count(' ') for s in sentences) + 1\n",
    "            "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def mostWordsFound(self, sentences: List[str]) -> int:\n",
    "        res=0\n",
    "        for ss in sentences:\n",
    "            temp=ss.count(' ')\n",
    "            res=max(res,temp+1)\n",
    "        return res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def mostWordsFound(self, sentences: List[str]) -> int:\n",
    "        s = 0\n",
    "        for j in sentences:\n",
    "            k = 1\n",
    "            for i in j:\n",
    "                if i == ' ':\n",
    "                    k += 1\n",
    "            s = max(k, s)\n",
    "\n",
    "        return s"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def mostWordsFound(self, sentences: List[str]) -> int:\n",
    "        return max(s.count(\" \")+ 1  for s in sentences)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def mostWordsFound(self, sentences: List[str]) -> int:\n",
    "        res = 0\n",
    "        for sentence in sentences:\n",
    "            #  单词数 = 空格数 + 1\n",
    "            cnt = sentence.count(' ') + 1\n",
    "            res = max(res, cnt)\n",
    "        return res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def mostWordsFound(self, sentences: List[str]) -> int:\n",
    "        res=0\n",
    "        for sentence in sentences:\n",
    "            con=sentence.count(\" \")+1\n",
    "            res = max(res,con)\n",
    "        return res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def mostWordsFound(self, sentences: List[str]) -> int:\n",
    "        res = 0\n",
    "        for s in sentences:\n",
    "            #  单词数 = 空格数 + 1\n",
    "            cnt = s.count(' ')+1\n",
    "            res = max(res,cnt)\n",
    "        return res\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def mostWordsFound(self, sentences: List[str]) -> int:\n",
    "        re = 0\n",
    "        for s in sentences:\n",
    "            if re<s.count(\" \"):\n",
    "                re = s.count(\" \")\n",
    "\n",
    "        return (re+1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def mostWordsFound(self, sentences: List[str]) -> int:\n",
    "        res = 0\n",
    "        for sentence in sentences:\n",
    "            res = max(res, len(sentence.split(' ')))\n",
    "        \n",
    "        return res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def mostWordsFound(self, sentences: List[str]) -> int:\n",
    "        lenth = 0\n",
    "        for i in sentences:\n",
    "            num = i.split(' ')\n",
    "            if len(num) > lenth:\n",
    "                lenth = len(num)\n",
    "        return lenth\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def mostWordsFound(self, sentences: List[str]) -> int:\n",
    "        ans=0\n",
    "        for i in sentences:\n",
    "            cnt=i.count(' ')+1\n",
    "            if ans<cnt:\n",
    "                ans=cnt\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def mostWordsFound(self, sentences: List[str]) -> int:\n",
    "        ans=0\n",
    "        for i in sentences:\n",
    "            ans=max(i.count(' ')+1,ans)\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def mostWordsFound(self, sentences: List[str]) -> int:\n",
    "        a = 0\n",
    "        for sentence in sentences:\n",
    "            count = sentence.count(' ') +1 \n",
    "            a = max(a,count)\n",
    "        return a"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def mostWordsFound(self, sentences: List[str]) -> int:\n",
    "        list = []\n",
    "        for i in sentences:\n",
    "            s = i.count(' ')\n",
    "            list.append(s)\n",
    "        return max(list)+1\n",
    "                "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def mostWordsFound(self, sentences: List[str]) -> int:\n",
    "        return max(x.count(\" \") for x in sentences) + 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def mostWordsFound(self, sentences: List[str]) -> int:\n",
    "        maxium = 0\n",
    "        for x in sentences:\n",
    "            tem = x.split()\n",
    "            n = len(tem)\n",
    "            if n > maxium:\n",
    "                maxium = n\n",
    "        return maxium"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def mostWordsFound(self, sentences: List[str]) -> int:\n",
    "        return max([len(i.split(' ')) for i in sentences])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def mostWordsFound(self, sentences: List[str]) -> int:\n",
    "        res = 1\n",
    "        for c in sentences:\n",
    "            empty = 0\n",
    "            res = max(res, sum(d == ' ' for d in c) + 1)\n",
    "        return res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def mostWordsFound(self, sentences: List[str]) -> int:\n",
    "        res = 0\n",
    "        for s in sentences:\n",
    "            l = s.split(' ')\n",
    "            res = max(res,len(l))\n",
    "        return res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def mostWordsFound(self, sentences: List[str]) -> int:\n",
    "        ans = 0\n",
    "        for sentence in sentences:\n",
    "            t = len(sentence.split(' '))\n",
    "            if  t > ans:\n",
    "                ans = t\n",
    "        return ans\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def mostWordsFound(self, sentences: List[str]) -> int:\n",
    "        return max([len(s.split(' ')) for s in sentences])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def mostWordsFound(self, sentences: List[str]) -> int:\n",
    "        ans = 0\n",
    "        for i in sentences:\n",
    "            ans = max(ans, len(i.split(' ')))\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def mostWordsFound(self, sentences: List[str]) -> int:\n",
    "        result = 0\n",
    "        for sentence in sentences:\n",
    "            count = len(sentence.split())\n",
    "            result = max(result, count)\n",
    "        return result\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def mostWordsFound(self, sentences: List[str]) -> int:\n",
    "        max = 0\n",
    "        for sent in sentences:\n",
    "            count = 0\n",
    "            for c in sent:\n",
    "                if c == \" \": count += 1\n",
    "            if count + 1 > max: max = count + 1\n",
    "        return max"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def mostWordsFound(self, sentences: List[str]) -> int:\n",
    "        res = 0\n",
    "        for sentence in sentences:\n",
    "            cnt = sentence.count(' ')+1\n",
    "            res = max(res,cnt)\n",
    "        return res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def mostWordsFound(self, sentences: List[str]) -> int:\n",
    "        space = [sentence.count(' ') for sentence in sentences]\n",
    "        return max(space) + 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def mostWordsFound(self, sentences: List[str]) -> int:\n",
    "        res = 0\n",
    "        for i in sentences:\n",
    "            n = i.count(' ') + 1\n",
    "            if n > res:\n",
    "                res = n\n",
    "        return res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def mostWordsFound(self, sentences: List[str]) -> int:\n",
    "\n",
    "        count = 0\n",
    "        count_max = 0\n",
    "        for date in sentences:\n",
    "        \n",
    "            count = len(date.split())\n",
    "            count_max = max(count, count_max)\n",
    "\n",
    "        return count_max"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def mostWordsFound(self, sentences: List[str]) -> int:\n",
    "        res = 0\n",
    "        count = 0\n",
    "        for sentence in sentences:\n",
    "            for s in sentence:\n",
    "                if s == ' ':\n",
    "                    count += 1\n",
    "            res = max(res, count)\n",
    "            count = 0\n",
    "        return res+1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def mostWordsFound(self, sentences: List[str]) -> int:\n",
    "        reg = 0\n",
    "        for i in sentences:\n",
    "            cnt = i.count(' ') + 1\n",
    "            reg = max(cnt, reg)\n",
    "        return reg"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def mostWordsFound(self, sentences: List[str]) -> int:\n",
    "        return max(i.count(' ') for i in sentences)+1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def mostWordsFound(self, sentences: List[str]) -> int:\n",
    "        a=[]\n",
    "        for s in sentences:\n",
    "            ls=s.split(\" \")\n",
    "            a.append(len(ls))\n",
    "        return max(a)\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def mostWordsFound(self, sentences: List[str]) -> int:\n",
    "        return max([len(sent.split(' ')) for sent in sentences])\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def mostWordsFound(self, sentences: List[str]) -> int:\n",
    "        s=0\n",
    "        for i in sentences:\n",
    "            l=i.count(' ')+1\n",
    "            if l>s:s=l\n",
    "        return s"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def mostWordsFound(self, sentences: List[str]) -> int:\n",
    "        ans=0\n",
    "        for i in sentences:\n",
    "            ans=max(len(i.split()),ans)\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def mostWordsFound(self, sentences: List[str]) -> int:\n",
    "        n = len(sentences)\n",
    "        nums = []\n",
    "        ans = 0\n",
    "        for i in range(n):\n",
    "            for j in range(n):\n",
    "                j = sentences[i].split()\n",
    "            num = len(j)\n",
    "            nums.append(num)\n",
    "        for a in nums:\n",
    "            if a >= ans:\n",
    "                ans = a\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def mostWordsFound(self, sentences: List[str]) -> int:\n",
    "        maximum = 0\n",
    "        for string in sentences:\n",
    "            words = string.split()\n",
    "            length = len(words)\n",
    "            if length > maximum:\n",
    "                maximum = length\n",
    "        return maximum\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def mostWordsFound(self, sentences: List[str]) -> int:\n",
    "        return max([len(sentence.split(\" \")) for sentence in sentences])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution(object):\n",
    "    def mostWordsFound(self, sentences):\n",
    "        return max(s.count(' ') for s in sentences) + 1\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def mostWordsFound(self, sentences: List[str]) -> int:\n",
    "        ans = 0\n",
    "        for x in sentences:\n",
    "            ans = max(ans, len(x.split(\" \")))\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def mostWordsFound(self, sentences: List[str]) -> int:\n",
    "        res = 0\n",
    "        for s in sentences:\n",
    "            cur = s.split()\n",
    "            res = max(res, len(cur))\n",
    "        return res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def mostWordsFound(self, sentences: List[str]) -> int:\n",
    "        return max(*(sentence.count(' ') for sentence in sentences), 0) + 1\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def mostWordsFound(self, sentences: List[str]) -> int:\n",
    "        return max(s.count(' ') for s in sentences)+1\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def mostWordsFound(self, sentences: List[str]) -> int:\n",
    "        count = 0\n",
    "        for v in sentences:\n",
    "\n",
    "            if len(v.split()) > count:\n",
    "                count = len(v.split())\n",
    "        return count"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def mostWordsFound(self, sentences: List[str]) -> int:\n",
    "        max_num = 0\n",
    "        for i in sentences:\n",
    "            n = len(i.split())\n",
    "            if n >= max_num:\n",
    "                max_num = n \n",
    "        return max_num"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def mostWordsFound(self, sentences: List[str]) -> int:\n",
    "        ans = 0\n",
    "        for x in sentences:\n",
    "            ans = max(ans, x.count(\" \") + 1)\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def mostWordsFound(self, sentences: List[str]) -> int:\n",
    "        return max(s.count(\" \")+ 1  for s in sentences)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def mostWordsFound(self, sentences: List[str]) -> int:\n",
    "        res=0\n",
    "        for x in sentences:\n",
    "            m = x.count(\" \")\n",
    "            res = max(res,m+1)\n",
    "        return res\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def mostWordsFound(self, sentences: List[str]) -> int:\n",
    "        numlist = []\n",
    "        for sentence in sentences:\n",
    "            sentence = sentence.split()\n",
    "            numlist.append(len(sentence))\n",
    "        return max(numlist)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def mostWordsFound(self, sentences: List[str]) -> int:\n",
    "        a=[]\n",
    "        for i in sentences:\n",
    "            a.append(i.count(\" \")+1)\n",
    "        return max(a)\n",
    "        \n",
    "\n",
    "\n",
    "\n",
    "\n",
    "            "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def mostWordsFound(self, sentences: List[str]) -> int:\n",
    "         return max(s.count(' ') for s in sentences)+1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def mostWordsFound(self, sentences: List[str]) -> int:\n",
    "        a = []\n",
    "\n",
    "        for i in range(len(sentences)):\n",
    "            a.append(len(sentences[i].split()))\n",
    "        a.sort(reverse=True)\n",
    "        return a[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def mostWordsFound(self, sentences: List[str]) -> int:\n",
    "        n = 0\n",
    "        for s in sentences:\n",
    "            cot = s.count(' ') + 1\n",
    "            if cot > n:\n",
    "                n = cot\n",
    "        return n \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def mostWordsFound(self, sentences: List[str]) -> int:\n",
    "        return max(len(sentence.split()) for sentence in sentences)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def mostWordsFound(self, sentences: List[str]) -> int:\n",
    "        ans = 0\n",
    "        for sentence in sentences:\n",
    "            t = len(sentence.split(' '))\n",
    "            if  t > ans:\n",
    "                ans = t\n",
    "        return ans\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def mostWordsFound(self, sentences: List[str]) -> int:\n",
    "        max_cnt = 0\n",
    "        for i in sentences:\n",
    "            cnt = 1\n",
    "            for j in i:\n",
    "                if j == ' ':\n",
    "                    cnt += 1\n",
    "            max_cnt = max(cnt,max_cnt)\n",
    "        return max_cnt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def mostWordsFound(self, sentences: List[str]) -> int:\n",
    "        re = 0\n",
    "        map(split, sentences)\n",
    "        for s in sentences:\n",
    "            ss = s.split(' ')\n",
    "            if len(ss) > re:\n",
    "                re = len(ss)\n",
    "        return re\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def mostWordsFound(self, sentences: List[str]) -> int:\n",
    "        num=0\n",
    "        for i in range(len(sentences)):\n",
    "            print(sentences[i])\n",
    "            a=sentences[i].split(' ')\n",
    "            print(a)\n",
    "            if len(a)>num:\n",
    "                num=len(a)\n",
    "        return num"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def mostWordsFound(self, sentences: List[str]) -> int:\n",
    "        return max(len(string.split()) for string in sentences)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def mostWordsFound(self, sentences: List[str]) -> int:\n",
    "        a = 0\n",
    "        for ss in sentences:\n",
    "            a = max(len(ss.split()), a)\n",
    "        return a"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def mostWordsFound(self, sentences: List[str]) -> int:\n",
    "        max_len = 0\n",
    "        for sentence in sentences:\n",
    "            len = sum(1 for char in sentence if char == ' ') + 1\n",
    "            if len > max_len:\n",
    "                max_len = len\n",
    "        return max_len\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def mostWordsFound(self, sentences: List[str]) -> int:\n",
    "        res = 0\n",
    "        for sentence in sentences:\n",
    "            cnt = sentence.count(' ')+1\n",
    "            res = max(res,cnt)\n",
    "        return res\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def mostWordsFound(self, sentences: List[str]) -> int:\n",
    "        return max(len(s.split()) for s in sentences)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def mostWordsFound(self, sentences: List[str]) -> int:\n",
    "\n",
    "        ans = 0\n",
    "        for i in range(len(sentences)):\n",
    "            sentence= sentences[i]\n",
    "            lst = sentence.split(' ')\n",
    "            ans = max(ans,len(lst))\n",
    "        return ans \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def mostWordsFound(self, sentences: List[str]) -> int:\n",
    "        ans = 0\n",
    "        def check(sentence):\n",
    "            return sum(1 for ch in sentence if ch == ' ')+1\n",
    "        for s in sentences:\n",
    "            ans = max(ans, check(s))\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def mostWordsFound(self, sentences: List[str]) -> int:\n",
    "        '''\n",
    "        res=0\n",
    "        for s in sentences:\n",
    "            res=max(res,Counter(s)[' '])\n",
    "        return res+1\n",
    "        '''\n",
    "        return max([s.count(' ') for s in sentences])+1"
   ]
  }
 ],
 "metadata": {},
 "nbformat": 4,
 "nbformat_minor": 2
}
